package itheima.com.socketdemo2Test;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Server {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(6000);

        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
        System.out.println("接受前");
        ds.receive(dp);
        System.out.println("接受后");

      /*  byte[] data = dp.getData();
        int length = dp.getLength();
        String s = new String(data,0,length);
        System.out.println(s);*/

        int length = dp.getLength();
        System.out.println(new String(bytes,0,length));
        ds.close();
    }
}
